public class MyQueue {
    public static class ListNode{
        public int val;
        public ListNode prev;
        public ListNode next;
        public ListNode(int val){
            this.val = val;
        }
    }
    public int usedSize = 0;
    public ListNode head = null;
    public ListNode last = null;

    public boolean isEmpty(){//检查是否为空
        return usedSize == 0;//如果是空的 , usedSize为0 返回true
    }

    public void offer(int val){//入队列,采用的是尾插法
        ListNode node = new ListNode(val);
        if(isEmpty()){
            head = last =  node;//把node节点赋值给head和last
            usedSize++;
        }else {
            last.next = node;
            node.prev = last;
            last = node;
            usedSize++;
        }
    }
    public int poll(){//相应的出队列应该采用,头删法
        if(isEmpty()) {
            return -1;
        }
            int vall = head.val;
            head = head.next;
            if(head != null){
                head.prev = null;
            }
            usedSize--;
        return vall;
    }
    public int size(){//返回大小
        return usedSize;
    }

}
